<template>
  <view class="tab-bar">
    <view
      v-for="(item, index) in list"
      :key="index"
      class="tab-bar-item"
      @click="switchTabFn(item, index)"
    >
      <image
        class="tab_img"
        :src="select == index ? item.selectedIconPath : item.iconPath"
      ></image>
      <view
        class="tab_text"
        :style="{ color: select == index ? selectedColor : color }"
        >{{ item.text }}
      </view>
    </view>
  </view>
</template>

<script>
import { mapState } from "vuex";

export default {
	
  props: {
    select: Number,
  },
  data() {
    return {
      color: "#000000",
      selectedColor: "#4053CD",
      list: [],
    };
  },
  beforeCreate() {
	
	uni.getStorage({
	  key: "tabbarArray",
	  success: (res) => {
	    this.list = res.data;
	  },
	  fail: (err) => {
	    uni.showToast({
	      title: "身份标识过期，请重新登录",
	      icon: "none",
	      duration: 1500,
	    });
	    setTimeout(() => {
	      uni.reLaunch({
	        url: "/pages/login/login",
	      });
	    }, 1500);
	  },
	});
  },
  computed: {
	 
  },
  methods: {
    switchTabFn(item, index) {
	
      let url = item.pagePath;
      uni.switchTab({
        url,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.tab-bar {
	
  z-index: 9999999999999999999999999;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100rpx;
  background: white;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom); // 适配iphoneX的底部
  box-shadow: 0 0 6rpx 0 rgba(0, 0, 0, 0.1);

  .tab-bar-item {
    flex: 1;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;

    .tab_img {
      width: 37rpx;
      height: 41rpx;
    }

    .tab_text {
      font-size: 20rpx;
      margin-top: 9rpx;
    }
  }
}
</style>
